package com.eascs.web.demo.dubbo.provider;

import java.util.List;

import javax.inject.Inject;

import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Service;
import com.eascs.app.log.Logger;
import com.eascs.app.log.LoggerFactory;
import com.eascs.web.demo.db.DbDemoEntity;
import com.eascs.web.demo.db.DbDemoService;
import com.eascs.web.demo.dubbo.api.DubboDemo;
import com.eascs.web.demo.dubbo.api.DubboDemoSeviceRequest;
import com.eascs.web.demo.dubbo.api.DubboDemoSeviceResponse;

@Service
@Component
public class DubboDemoImpl implements DubboDemo {
	private final Logger logger = LoggerFactory.getLogger(DubboDemoImpl.class);
	@Inject
	private DbDemoService dbDemoService;

	@Override
	public DubboDemoSeviceResponse call(DubboDemoSeviceRequest dubboDemoSeviceRequest) {
		DubboDemoSeviceResponse dubboDemoSeviceResponse = new DubboDemoSeviceResponse();
		dubboDemoSeviceResponse.setName(dubboDemoSeviceRequest.getName() + ":" + System.currentTimeMillis());
		logger.debug("DubboDemoServiceImpl currentThread={}", Thread.currentThread().getId());
		return dubboDemoSeviceResponse;
	}

	@Override
	public void clean() {
		dbDemoService.clean();

	}

	@Override
	public void init() {
		dbDemoService.init();

	}

	@Override
	public void add(DbDemoEntity dbDemoEntity) {
		dbDemoService.add(dbDemoEntity);
	}

	@Override
	public void testTransactional() {
		dbDemoService.testTransactional();
	}

	@Override
	public void testTransactional(boolean success) {
		dbDemoService.testTransactional(success);

	}

	@Override
	public List<DbDemoEntity> list() {
		return dbDemoService.list();
	}

}
